

package com.eliza.module.view.work.imageprocessing;

/**
 * Image Processing Activity
 */
//public class ImageProcessingActivity extends ComponentActivity {
//    private static final int IMAGE_REQUEST_CODE = 1;
//    private static final String TAG = "ImageProcessingActivity";
//    private ImageRecyclerViewAdapter mImageRecyclerViewAdapter;
//
//    @Override
//    protected void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_image_processing);
//
//        mImageRecyclerViewAdapter = new ImageRecyclerViewAdapter();
//
//        RecyclerView mRecyclerView = findViewById(R.id.image_recycler_view);
//        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
//        mRecyclerView.setAdapter(mImageRecyclerViewAdapter);
//
//        TestDatabase.getInstance(this)
//                .getImageDao()
//                .getImagesLiveData()
//                .observe(this, new Observer<List<Image>>() {
//                    @Override
//                    public void onChanged(List<Image> images) {
//                        mImageRecyclerViewAdapter.updateList(images);
//                    }
//                });
//
//        findViewById(R.id.add_image).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Intent chooseIntent = new Intent(
//                        Intent.ACTION_PICK,
//                        MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
//                chooseIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
//                startActivityForResult(chooseIntent, IMAGE_REQUEST_CODE);
//            }
//        });
//
//
//        findViewById(R.id.clear_all).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                WorkManager.getInstance(ImageProcessingActivity.this)
//                        .enqueue(OneTimeWorkRequest.from(ImageCleanupWorker.class));
//            }
//        });
//    }
//
//
//    @Override
//    @SuppressLint("MissingSuperCall")
//    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//        if (requestCode == IMAGE_REQUEST_CODE && resultCode == Activity.RESULT_OK
//                && data.getClipData() != null) {
//            Log.d(TAG, "Image Selection Complete");
//            int count = data.getClipData().getItemCount();
//            OneTimeWorkRequest[] processingWork = new OneTimeWorkRequest[count];
//            OneTimeWorkRequest[] setupWork = new OneTimeWorkRequest[count];
//            for (int i = 0; i < count; i++) {
//                String uriString = data.getClipData().getItemAt(i).getUri().toString();
//                setupWork[i] = ImageSetupWorker.createWork(uriString);
//                processingWork[i] = ImageProcessingWorker.createWork(uriString);
//            }
//            WorkManager.getInstance(ImageProcessingActivity.this)
//                    .beginWith(Arrays.asList(setupWork))
//                    .then(Arrays.asList(processingWork))
//                    .enqueue();
//        } else if (requestCode == IMAGE_REQUEST_CODE && resultCode == Activity.RESULT_OK
//                && data.getData() != null) {
//            Log.d(TAG, "Image Selection Complete");
//            String uriString = data.getData().toString();
//            OneTimeWorkRequest setupWork = ImageSetupWorker.createWork(uriString);
//            OneTimeWorkRequest processingWork = ImageProcessingWorker.createWork(uriString);
//            WorkManager.getInstance(ImageProcessingActivity.this)
//                    .beginWith(setupWork)
//                    .then(processingWork)
//                    .enqueue();
//        } else if (requestCode == IMAGE_REQUEST_CODE && resultCode == Activity.RESULT_CANCELED) {
//            Log.d(TAG, "Image Selection Cancelled");
//        } else {
//            throw new UnsupportedOperationException();
//        }
//    }
//}
